package com.tkc.converter;

import java.sql.Timestamp;
import java.util.HashMap;

import com.tkc.common.util.RandomUtil;
import com.tkc.dao.model.doo.TeacherDOO;
import com.tkc.service.model.dto.TeacherDTO;

/**
 * 
 * @Function:用于service层到dao层对象数据的转换
 * 
 * @Project :assessmenttask 
 * @Package :com.tkc.converter 
 * @File :DTOConvertToDOO.java 
 * @ClassName: DTOConvertToDOO  
 * 
 * @author tankaichao 
 * @email cgztkc@126.com 
 * @Date 2016年8月9日下午6:08:19
 * @since JDK 1.8 
 *
 */
public class DTOConvertToDOO {

	public static TeacherDOO convertFromTeacherDTOToTeacherDOO(TeacherDTO teacherDTO) {
		TeacherDOO teacherDOO = new TeacherDOO();
		teacherDOO.setId(teacherDTO.getId());
		teacherDOO.setName(teacherDTO.getName());
		teacherDOO.setPassword(teacherDTO.getPassword());
		teacherDOO.setSex(teacherDTO.getSex());
		teacherDOO.setDesc(teacherDTO.getDesc());
		teacherDOO.setPicUrl(teacherDTO.getPicUrl());
		teacherDOO.setSchoolName(teacherDTO.getSchoolName());
		if (null !=teacherDTO.getRegistDate()) {
			teacherDOO.setRegistDate(Timestamp.valueOf(teacherDTO.getRegistDate()));
		}
		teacherDOO.setRemark(teacherDTO.getRemark());
		return teacherDOO;
	}
	
	public static HashMap<String, String> convertFromTeacherDTOToTeacherDOOMap(TeacherDTO teacherDTO){
		HashMap<String, String> map = new HashMap <String,String>();
		map.put("id", RandomUtil.getLetterRandom());
		map.put("name", teacherDTO.getName());
		map.put("password", teacherDTO.getPassword());
		map.put("sex", teacherDTO.getSex());
		map.put("desc", teacherDTO.getDesc());
		map.put("picUrl", teacherDTO.getPicUrl());
		map.put("schoolName", teacherDTO.getSchoolName());
		map.put("registDate", teacherDTO.getRegistDate());
		map.put("remark", teacherDTO.getRemark());
		return map;
	}
}
